home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / Meshwriter / utilities.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  2.7 KB  |  71 lines

  1. /*
  2. **      $VER: utilities.c 1.00 (13.02.1999)
  3. **
  4. **      Creation date : 02.01.1999
  5. **
  6. **      Description       :
  7. **         Utilities module for meshwriter.library.
  8. **
  9. **
  10. **      Written by Stephan Bielmann
  11. **
  12. */
  13.  
  14. /*************************** Includes *******************************/
  15.  
  16. /*
  17. ** Amiga includes
  18. */
  19. #include <exec/types.h>
  20.  
  21. /********************** Private functions ***************************/
  22.  
  23. /********************** Public functions ****************************/
  24.  
  25. /********************************************************************\
  26. *                                                                    *
  27. * Name         : setUBYTEArray                                       *
  28. *                                                                    *
  29. * Description  : Copies an array of n UBYTEs into another one.       *
  30. *                                                                    *
  31. * Arguments    : array IN/OUT: The array to copy into.               *
  32. *                text  IN    : Text to copy into the array.          *
  33. *                size  IN    : Size of output array.                 *
  34. *                                                                    *
  35. * Comment      :                                                     *
  36. *                                                                    *
  37. \********************************************************************/
  38. VOID setUBYTEArray(UBYTE *array,STRPTR text,ULONG size) {
  39.     UBYTE i,j;
  40.     
  41.     for(i=0;i<size && text[i]!='\0';i++) array[i]=text[i];
  42.     for(j=i;j<size;j++) array[j]='\0';  
  43. }
  44.  
  45. /********************************************************************\
  46. *                                                                    *
  47. * Name         : stringlen                                           *
  48. *                                                                    *
  49. * Description  : Returns the length of a '\0' terminated string.     *
  50. *                                                                    *
  51. * Arguments    : string IN  : String to process.                     *
  52. *                                                                    *
  53. * Return Value : Lenght of the string.                               *
  54. *                                                                    *
  55. * Comment      : To prevent endless loops if no '\0' is found, the   *
  56. *                lenght is limited to 10000.                         *
  57. *                                                                    *
  58. \********************************************************************/
  59. ULONG stringlen (STRPTR string) {
  60.     ULONG i;
  61.     
  62.     if(!string) return(0);
  63.     
  64.     i=0;
  65.     while(i<10000 && string[i]!='\0') i++;
  66.  
  67.     return(i);
  68. }
  69.  
  70. /************************* End of file ******************************/
  71.